﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AIVOnline./*TopologyModel.*/PathModel
{
    /// <summary>
    /// 有向图的边
    /// </summary>
    /// 
    [Table("Edge")]
    public partial class Edge
    {

        [Key, Column(Order = 1)]
        public int EId { get; set; }


        //public int Enode { get; set; }    // 多余

        /// <summary>
        /// 起始NodeId
        /// </summary>
        //[Column(Order = 2)]
        public int startNode { get; set; }

        /// <summary>
        /// 终止NodeId
        /// </summary>
        public int endNode { get; set; }

        /// <summary>
        /// 距离/权重
        /// </summary>
        public double distance { get; set; } = 1;

        #region  状态和连通性

        /// <summary>
        /// 连接边的方向;
        /// 一般情况下，点位放置物品和车辆到达后，该点位相关的路径都不可用。
        /// 还有一种特殊情况，点位上放置支撑货架后，在某方向上还可以低位从货架下通行。
        /// </summary>
        public EdgeDirection edgeDirection { get; set; } = EdgeDirection.None;

        /// <summary>
        /// 该路径的可用状态。
        /// </summary>
        public EdgeState edgeState { get; set; } = EdgeState.Normal;

        #endregion 状态和连通性
    }

    /// <summary>
    /// 
    /// </summary>
    public enum EdgeState
    {
        /// <summary>
        /// 不存在/不用
        /// </summary>
        NoExist = 0,
        NonUsed = 0,

        /// <summary>
        /// 正常使用
        /// </summary>
        Normal = 1,

        /// <summary>
        /// 受限可用
        /// </summary>
        Limited = 2,
        
        /// <summary>
        /// 被阻挡，不可用
        /// </summary>
        Blocked = 4,
    }

    /// <summary>
    /// 路径方向 (从原点至终点) -- 以绘制的现场工作地图为方向基础
    /// </summary>
    public enum EdgeDirection
    {
        /// <summary>
        /// 无需关注
        /// </summary>
        None = 0,

        /// <summary>
        ///  前方/北方
        /// </summary>
        FrontOrNorth = 1,   //1<<0

        /// <summary>
        /// 右方/东方
        /// </summary>
        RightOrEast = 2,    //1<<1

        /// <summary>
        /// 后方/南方
        /// </summary>
        BackOrSouth = 4,    //1<<2


        /// <summary>
        /// 左边/西方
        /// </summary>
        LeftOrWest = 8,     //1<<3

        // 4个象限里的1/4弧度
        Arc_Quarter_1 = 32,
        Arc_Quarter_2 ,
        Arc_Quarter_3 ,
        Arc_Quarter_4 ,

        // 半弧度
        ArcHalf_1 ,
        ArcHalf_2 , 
        ArcHalf_3 ,
        ArcHalf_4 ,
    }
}
